#include <iostream>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <deque>

using namespace std;

typedef int arr[1000];
typedef arr tarr[1000];

arr price, tcooking, teating, tsafe, c, e, accept, tarrive;
tarr dish, mwait, id, tstart, tsupport;
map<int, int> cooker[1000];
int n, m, q;

struct request_t
{
	int dish_id;
	int start_time;
};

bool compare_r(const request_t &a, const request_t &b)
{
	return a.start_time < b.start_time;
}

int main()
{
	cin >> n >> m >> q;
	
	for (int i = 0; i < n; ++i)
	    cin >> price[i] >> tcooking[i] >> teating[i] >> tsafe[i];
	    
	for (int i = 0; i < m; ++i)
    {
		cin >> c[i];
		cooker[i].clear();
		for (int j = 0; j < c[i]; ++j)
		{
			int u, v;
			cin >> u >> v;
			cooker[i][u] = v;
		}
	}
	
	for (int i = 0; i < q; ++i)
	{
		cin >> tarrive[i];
		cin >> e[i];
		for (int j = 0; j < e[i]; ++j)
			cin >> dish[i][j] >> mwait[i][j];
	}
	
	bool pass = true;
	
	int x;
	cin >> x;
	for (int i = 0; i < q; ++i)
	{
		cin >> accept[i];
		if (accept[i] == 1)
		{
			for (int j = 0; j < e[i]; ++j)
				cin >> id[i][j] >> tstart[i][j] >> tsupport[i][j];
		}
	}
	
	int earn = 0;
	
	for (int i = 0; i < q; ++i) if (accept[i] == 1)
	{
		for (int j = 0; j < e[i]; ++j)
		{
			earn += price[dish[i][j]];
			if (tstart[i][j] + tcooking[dish[i][j]] + tsafe[dish[i][j]] < tsupport[i][j]) pass = false;
			if (tsupport[i][j] - tstart[i][j] < tcooking[dish[i][j]]) pass = false;
			if (j < e[i] - 1 && tsupport[i][j] + teating[dish[i][j]] + mwait[i][j + 1] < tsupport[i][j + 1]) pass = false;
		}
		if (e[i] > 0 && tsupport[i][0] > tarrive[i] + mwait[i][0]) pass = false;
	}
	
	if (earn != x) pass = false;

	for (int k = 0; k < m; ++k)
	{
		vector<request_t> rq;
		
		for (int i = 0; i < q; ++i) if (accept[i] == 1)
		{
			for (int j =0 ; j < e[i]; ++j) if (id[i][j] == k)
			{
				request_t r;
				r.dish_id = dish[i][j];
				r.start_time = tstart[i][j];
				if (cooker[k].find(r.dish_id) == cooker[k].end())
				    pass = false;
				else
				    rq.push_back(r);
			}
		}
		sort(rq.begin(), rq.end(), compare_r);
		
		int base = - (1 << 30);
		
		for (int i = 0; i < rq.size(); )
		{
			if (rq[i].start_time < base) pass = false;
			base = rq[i].start_time + tcooking[rq[i].dish_id];
			int j = i;
			while (j < rq.size() && rq[i].start_time == rq[j].start_time)
			{
				if (rq[i].dish_id != rq[j].dish_id) pass = false;
				j ++;
			}
			if (j - i > cooker[k][rq[i].dish_id]) pass = false;
			i = j;
		}
	}
	
	if (pass)
	    puts("YES");
	else
	    puts("NO");
	
	getc(stdin);
	getc(stdin);
	return 0;
}
